import Cookies from 'js-cookie'

const TokenKey = 'token'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

export function setKey(key) {
  return Cookies.set('key', key)
}
export function getKey() {
  return Cookies.get('key')
}
export function removeKey() {
  return Cookies.remove('key')
}
export function removeToken() {
  return Cookies.remove(TokenKey)
}


  /**
   * 设置缓存信息
   * @param key
   * @param data
   */
  export function setLocalStorage(key, data) {
    return window.localStorage.setItem(key, JSON.stringify(data));
  }

  /**
   * 获取指定缓存信息
   * @param key
   */
  export function getLocalStorage(key) {
    if (window.localStorage.getItem(key) == "undefined") {
      return undefined
    } else {
      return JSON.parse(window.localStorage.getItem(key));
    }
  }

  /**
   * 删除指定缓存
   * @param key
   */
  export function removeLocalStorage(key) {
    return window.localStorage.removeItem(key);
  }



